<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>底部</title>
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
</head>
<body>
  <!-- <header class="aui-bar aui-bar-nav" id="aui-header">顶部导航栏</header> -->
  <footer class="aui-bar aui-bar-tab" id="footer">
        <div id="tabbar1" class="aui-bar-tab-item aui-active" tapmode onclick="randomSwitchBtn(this,'信用查询',0)">
            <i class="aui-iconfont aui-icon-search"></i>
            <div class="aui-bar-tab-label">评分查询</div>
        </div>
        <div id="tabbar2" class="aui-bar-tab-item" tapmode onclick="randomSwitchBtn(this,'车贷计算',1)">
            <i class="aui-iconfont aui-icon-pencil"></i>
            <div class="aui-bar-tab-label">车贷计算</div>
        </div>
      <div id="tabbar3" class="aui-bar-tab-item" tapmode onclick="randomSwitchBtn(this,'同盾查询',2)">
          <i class="aui-iconfont aui-icon-pencil"></i>
          <div class="aui-bar-tab-label">同盾查询</div>
      </div>
  </footer>
</body>
<script type="text/javascript" src="./lib/api.js"></script>
<script type="text/javascript">
  apiready = function(){
        api.parseTapmode();
        // var header = $api.byId('aui-header');
        var footer =　$api.byId('footer')
        // $api.fixStatusBar(header);
        // var headerPos = $api.offset(header);
        var body_h = api.winHeight;
        var footer_h = $api.offset(footer).h;

        api.openFrameGroup ({
            name: 'footer_tab_demo',
            scrollEnabled:true,
            rect:{x:0, y:0,w:'auto',h:body_h-footer_h+5},
            index:0,
            preload:3,
            frames:
            [{
                name: 'creditScoreQuery',
                url: 'creditScore/creditScoreQuery.html',
                bounces:false
            },{
                name: 'carLoanCal',
                url: 'carLoanCal/carLoanCal.html',
                bounces:false
            },{
              name: 'tongDunQuery',
              url: 'tongDun/tongDunQuery.html',
              bounces:false
            }]
        },
        function(ret, err){
            var footer = $api.byId('footer');
            var footerAct = $api.dom(footer, '.aui-bar-tab-item.aui-active');
            $api.removeCls(footerAct, 'aui-active');

            var name = ret.name;
            var index = ret.index;
            if(index==0){
                $api.addCls($api.byId('tabbar1'), 'aui-active');
            }else if(index==1){
                $api.addCls($api.byId('tabbar2'), 'aui-active');
            }else if(index==2){
              $api.addCls($api.byId('tabbar3'), 'aui-active');
            }
        })

    }
    function closeWin(){
        api.closeWin();
    }
    function randomSwitchBtn(obj, name, index) {
        // $api.text($api.byId('aui-header'),name);
      	var footer = $api.byId('footer');
      	var footerAct = $api.dom(footer, '.aui-bar-tab-item.aui-active');
              $api.removeCls(footerAct, 'aui-active');
              $api.addCls(obj, 'aui-active');
              console.log(index);
              api.setFrameGroupIndex({
                  name: 'footer_tab_demo',
                  index: index,
                  scroll:true,
                  reload:true
        });

    }
</script>
</html>
